﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace Knights
{
    abstract class Modelo
    {
        protected List<VertexPositionNormalTexture> vertices = new List<VertexPositionNormalTexture>();
        private VertexBuffer datos;

        public virtual void Inicializar()
        {
            datos = new VertexBuffer(Juego.Device, typeof(VertexPositionNormalTexture), vertices.Count, BufferUsage.WriteOnly);
            datos.SetData(vertices.ToArray());
        }

        public virtual void Dibujar(Matrix world, Effect efecto)
        {
            efecto.Parameters["world"].SetValue(world);
            efecto.Parameters["view"].SetValue(Camara.Vista);
            efecto.Parameters["projection"].SetValue(Camara.Proyeccion);
            efecto.CurrentTechnique.Passes[0].Apply();

            Juego.Device.SetVertexBuffer(datos);
            Juego.Device.DrawPrimitives(PrimitiveType.TriangleList, 0, datos.VertexCount / 3);
        }
    }
}
